},
_allocate: function(actor, box, flags) {
+ let width = box.x2 - box.x1;
let height = box.y2 - box.y1;
let direction = this.actor.get_text_direction();
this._ornamentLabel.allocate(ornamentBox, flags);
- let x;
- if (direction == Clutter.TextDirection.LTR)
- x = box.x1;
- else
- x = box.x2;
- // if direction is ltr, x is the right edge of the last added
- // actor, and it's constantly increasing, whereas if rtl, x is
- // the left edge and it decreases
+ let x = box.x1;
for (let i = 0, col = 0; i < this._children.length; i++) {
let child = this._children[i];
let childBox = new Clutter.ActorBox();
let [minWidth, naturalWidth] = child.actor.get_preferred_width(-1);
- let availWidth, extraWidth;
- if (this._columnWidths) {
- if (child.span == -1) {
- if (direction == Clutter.TextDirection.LTR)
- availWidth = box.x2 - x;
- else
- availWidth = x - box.x1;
- } else {
+
+ let availWidth;
+ if (child.span == -1) {
+ availWidth = box.x2 - x;
+ } else {
+ if (this._columnWidths) {
availWidth = 0;
for (let j = 0; j < child.span; j++)
availWidth += this._columnWidths[col++];
- }
- extraWidth = availWidth - naturalWidth;
- } else {
- if (child.span == -1) {
- if (direction == Clutter.TextDirection.LTR)
- availWidth = box.x2 - x;
- else
- availWidth = x - box.x1;
} else {
availWidth = naturalWidth;
}
- extraWidth = 0;
}
- if (direction == Clutter.TextDirection.LTR) {
- if (child.expand) {
- childBox.x1 = x;
- childBox.x2 = x + availWidth;
- } else if (child.align === St.Align.MIDDLE) {
- childBox.x1 = x + Math.round(extraWidth / 2);
- childBox.x2 = childBox.x1 + naturalWidth;
- } else if (child.align === St.Align.END) {
- childBox.x2 = x + availWidth;
- childBox.x1 = childBox.x2 - naturalWidth;
- } else {
- childBox.x1 = x;
- childBox.x2 = x + naturalWidth;
- }
- } else {
- if (child.expand) {
- childBox.x1 = x - availWidth;
- childBox.x2 = x;
- } else if (child.align === St.Align.MIDDLE) {
- childBox.x1 = x - Math.round(extraWidth / 2);
- childBox.x2 = childBox.x1 + naturalWidth;
- } else if (child.align === St.Align.END) {
- // align to the left
- childBox.x1 = x - availWidth;
- childBox.x2 = childBox.x1 + naturalWidth;
- } else {
- // align to the right
- childBox.x2 = x;
- childBox.x1 = x - naturalWidth;
- }
- }
+ if (direction == Clutter.TextDirection.RTL)
+ childBox.x1 = width - x - availWidth;
+ else
+ childBox.x1 = x;
+ childBox.x2 = childBox.x1 + availWidth;
let [minHeight, naturalHeight] = child.actor.get_preferred_height(childBox.x2 - childBox.x1);
childBox.y1 = Math.round(box.y1 + (height - naturalHeight) / 2);
childBox.y2 = childBox.y1 + naturalHeight;
- child.actor.allocate(childBox, flags);
+ let [xAlign, yAlign] = St.get_align_factors(child.align,
+ St.Align.MIDDLE);
- if (direction == Clutter.TextDirection.LTR)
- x += availWidth + this._spacing;
- else
- x -= availWidth + this._spacing;
+ // It's called "expand", but it's really more like "fill"
+ let xFill = child.expand;
+ child.actor.allocate_align_fill(childBox,
+ xAlign, yAlign,
+ xFill, true,
+ flags);
+ x += availWidth + this._spacing;
}
}
});
return;
st_bin_get_alignment (ST_BIN (self), &x_align, &y_align);
- _st_get_align_factors (x_align, y_align,
- &x_align_factor, &y_align_factor);
+ st_get_align_factors (x_align, y_align,
+ &x_align_factor, &y_align_factor);
clutter_actor_get_allocation_box (CLUTTER_ACTOR (self), &self_box);
clutter_actor_get_allocation_box (child, &child_box);
gdouble x_align_f, y_align_f;
st_theme_node_get_content_box (theme_node, box, &childbox);
- _st_get_align_factors (priv->x_align, priv->y_align,
- &x_align_f, &y_align_f);
+ st_get_align_factors (priv->x_align, priv->y_align,
+ &x_align_f, &y_align_f);
clutter_actor_allocate_align_fill (priv->child, &childbox,
x_align_f, y_align_f,
priv->x_fill, priv->y_fill,
"expand", &expand,
NULL);
- _st_get_align_factors (xalign, yalign, &xalign_f, &yalign_f);
+ st_get_align_factors (xalign, yalign, &xalign_f, &yalign_f);
if (priv->is_vertical)
{
clutter_actor_get_preferred_height (actor, for_width, min_height_p, natural_height_p);
}
-/**
- * _st_get_align_factors:
- * @x_align: an #StAlign
- * @y_align: an #StAlign
- * @x_align_out: (out) (allow-none): @x_align as a #gdouble
- * @y_align_out: (out) (allow-none): @y_align as a #gdouble
- *
- * Converts @x_align and @y_align to #gdouble values.
- */
-void
-_st_get_align_factors (StAlign x_align,
- StAlign y_align,
- gdouble *x_align_out,
- gdouble *y_align_out)
-{
- if (x_align_out)
- {
- switch (x_align)
- {
- case ST_ALIGN_START:
- *x_align_out = 0.0;
- break;
-
- case ST_ALIGN_MIDDLE:
- *x_align_out = 0.5;
- break;
-
- case ST_ALIGN_END:
- *x_align_out = 1.0;
- break;
-
- default:
- g_warn_if_reached ();
- break;
- }
- }
-
- if (y_align_out)
- {
- switch (y_align)
- {
- case ST_ALIGN_START:
- *y_align_out = 0.0;
- break;
-
- case ST_ALIGN_MIDDLE:
- *y_align_out = 0.5;
- break;
-
- case ST_ALIGN_END:
- *y_align_out = 1.0;
- break;
-
- default:
- g_warn_if_reached ();
- break;
- }
- }
-}
-
/**
* _st_set_text_from_style:
* @text: Target #ClutterText
ClutterActor *_st_widget_get_dnd_clone (StWidget *widget);
-void _st_get_align_factors (StAlign x_align,
- StAlign y_align,
- gdouble *x_align_out,
- gdouble *y_align_out);
-
void _st_actor_get_preferred_width (ClutterActor *actor,
gfloat for_height,
gboolean y_fill,
row_span = meta->row_span;
col_span = meta->col_span;
- _st_get_align_factors (meta->x_align, meta->y_align,
- &x_align_f, &y_align_f);
+ st_get_align_factors (meta->x_align, meta->y_align,
+ &x_align_f, &y_align_f);
if (ltr)
{
row_span = meta->row_span;
col_span = meta->col_span;
- _st_get_align_factors (meta->x_align, meta->y_align,
- &x_align_f, &y_align_f);
+ st_get_align_factors (meta->x_align, meta->y_align,
+ &x_align_f, &y_align_f);
/* initialise the width and height */
col_width = col_widths[col];
{
return ST_WIDGET_GET_CLASS (widget)->get_focus_chain (widget);
}
+
+/**
+ * st_get_align_factors:
+ * @x_align: an #StAlign
+ * @y_align: an #StAlign
+ * @x_align_out: (out) (allow-none): @x_align as a #gdouble
+ * @y_align_out: (out) (allow-none): @y_align as a #gdouble
+ *
+ * Converts @x_align and @y_align to #gdouble values.
+ */
+void
+st_get_align_factors (StAlign x_align,
+ StAlign y_align,
+ gdouble *x_align_out,
+ gdouble *y_align_out)
+{
+ if (x_align_out)
+ {
+ switch (x_align)
+ {
+ case ST_ALIGN_START:
+ *x_align_out = 0.0;
+ break;
+
+ case ST_ALIGN_MIDDLE:
+ *x_align_out = 0.5;
+ break;
+
+ case ST_ALIGN_END:
+ *x_align_out = 1.0;
+ break;
+
+ default:
+ g_warn_if_reached ();
+ break;
+ }
+ }
+
+ if (y_align_out)
+ {
+ switch (y_align)
+ {
+ case ST_ALIGN_START:
+ *y_align_out = 0.0;
+ break;
+
+ case ST_ALIGN_MIDDLE:
+ *y_align_out = 0.5;
+ break;
+
+ case ST_ALIGN_END:
+ *y_align_out = 1.0;
+ break;
+
+ default:
+ g_warn_if_reached ();
+ break;
+ }
+ }
+}
GList * st_widget_get_focus_chain (StWidget *widget);
void st_widget_paint_background (StWidget *widget);
-
/* debug methods */
char *st_describe_actor (ClutterActor *actor);
void st_set_slow_down_factor (gfloat factor);
const gchar *name);
const gchar * st_widget_get_accessible_name (StWidget *widget);
+/* utility methods */
+void st_get_align_factors (StAlign x_align,
+ StAlign y_align,
+ gdouble *x_align_out,
+ gdouble *y_align_out);
+
G_END_DECLS
#endif /* __ST_WIDGET_H__ */